<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,
        body {
            height: 100%;
        }

        .container {
            padding: 10px;
            background-color: lightgrey;
        }

        .position {
            position: relative;
            margin: 10px;
            padding: 10px;
            border: 2px solid #ffd365;
            width: 100px;
            height: 100px;
        }

        .item {
            padding: 10px;
            margin: 10px;
            /* background-color: rgb(171, 185, 208); */
            border: 1px dashed skyblue;
        }
        .normal{
            width: 100px;
            height: 100px;
            border: 2px solid #ffd365;
        }
    </style>
</head>

<body>
    <!-- 学习一下事件的offset、page、client 系列 -->
    <div class="container">
        <div class="position">
            <div class="item"></div>
        </div>
        <div class="normal">

        </div>
    </div>

    <script>
        function handle(event) {
            event = event || window.event;
            console.log('offsetX', event.offsetX);
            console.log('offsetY', event.offsetY);
            console.log('offsetLeft', event.offsetLeft);
            console.log('offsetTop', event.offsetTop);
            console.log('offsetWidth', event.offsetWidth);
            console.log('offsetHeight', event.offsetHeight);
            console.log('target', event);
            event.stopPropagation();
        }

        // document.addEventListener('click', handle);
        let divs = document.querySelectorAll('div');
        divs.forEach(item=>{
            item.addEventListener('click',handle)
        })
    </script>
</body>

</html>